﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;

public partial class Management_Thongtinbenhnhan : System.Web.UI.UserControl
{
    public void loadThongTin(int IDPatient)
    {
        SqlConnection con = new SqlConnection(GlobalConstant.CONNECTION_STRING);
        con.Open();
        string sql = "SELECT * FROM tbImpatient INNER JOIN tbPatient ON tbImpatient.IDPatient=tbPatient.ID INNER JOIN tbAppointment ON tbImpatient.IDAppointment=tbAppointment.ID WHERE tbImpatient.IDPatient=" + IDPatient;
        SqlCommand cmd = new SqlCommand(sql, con);
        SqlDataReader reader = cmd.ExecuteReader();
        if (reader.Read())
        {
            lbID.Text = reader.GetInt32(0).ToString();
            lbFirstName.Text = reader.GetString(13);
            lbLastName.Text = reader.GetString(14);
            lbAddress.Text = reader.GetString(15);
            lbSex.Text = reader.GetInt32(16) == 0 ? "Nam" : "Nữ";
            lbTel.Text = reader.GetString(17);
            lbDOB.Text = reader.GetDateTime(18).ToString("dd-MM-yyyy");
            lbMariralStatus.Text = reader.GetString(19);            
            
            lbNFullName.Text = reader.GetString(8);
            lbNRelation.Text = reader.GetString(9);
            lbNAddress.Text = reader.GetString(10);
            lbNTel.Text = reader.GetString(11);
            lbDateReg.Text = reader.GetDateTime(26).ToString("dd/MM/yyyy");
            lbLFullName.Text = reader.GetString(27);
            lbLClinicNo.Text = reader.GetString(28);
            lblAddress.Text = reader.GetString(29);
            lbLTel.Text = reader.GetString(30);            
        }
        reader.Close();
        con.Close();
        pnTT.Visible = true;
    }

    public void setVisible(bool visible)
    {
        pnTT.Visible = visible;
    }
}